<?php

/**
 * @author honestphan
 * @copyright 2011
 */
 // no direct access

defined('DSVH') or die('Restricted access');

function dbconnect (){
    static $connect= null;
    if($connect == null){
        $connect = mysql_connect('localhost','bacgmfro_usvtb','huongliem');
        mysql_select_db('bacgmfro_svtb');
        mysql_query("SET NAMES 'utf8'", $connect);
		mysql_query("SET CHARACTER SET utf8", $connect);
		mysql_query("SET CHARACTER_SET_CONNECTION=utf8", $connect);
		mysql_query("SET SQL_MODE = ''", $connect);
    }
     return $connect;
}

function escape($value){
    return mysql_real_escape_string($value);
}

function filter($keywords){
   $keywords = str_replace("_","\_",$keywords);
   $keywords = str_replace("%","\%",$keywords);
   return $keywords;
}

function checkrangbuocdulieu($table,$column,$param){
    $sql = "SELECT * FROM '".$table."' where  '".$column."' = '".escape($param)."'";
    $result = mysql_query($sql, dbconnect());
    return mysql_num_rows($result);
}


?>